package com.welkin.cloudtest.prividerS.Service;

import com.welkin.cloudtest.prividerS.Entity.Payment;
import com.welkin.cloudtest.prividerS.Mapper.PaymentDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * TODO:请描述本类的作用
 * @version 1.0
 * @update 【1】【2021/3/4 15:49】【welkin】【创建】
 */
@Service
@Slf4j
public class PaymentServiceImpl implements PaymentService {

    @Autowired
    private PaymentDao paymentDao;

    @Override
    public int insert(Payment payment) {
        try {
            payment.setInfo(InetAddress.getLocalHost().getHostAddress());
        } catch (UnknownHostException e) {
            payment.setInfo("err");
        }
        log.info("impl=>待保存数据[{}]", payment);
        return paymentDao.insert(payment);
    }

    @Override
    public Payment getPaymentById(Long id) {
        return paymentDao.getPaymentById(id);
    }
}
